using System;
using System.Collections.Generic;
using System.Text;
using TVDesigner.Entities.Elements;
using TVDesigner.Entities;

namespace TVDesigner.Generator.GeneratorEntities
{
    public class HIconGenerator : GenericComponentGenerator
    {
        private HIcon _HIcon;

        public HIconGenerator(HIcon hIcon)
            : base(hIcon)
        {
            _HIcon = hIcon;
        }

        public override string TypeString
        {
            get { return "org.havi.ui.HStaticIcon"; }
        } 

        protected override void _SetAttributes(StringBuilder sb)
        {
            if (_HIcon.Imagem != null && !_HIcon.Imagem.Equals(string.Empty))
            {
                ImageFile imageFile = new ImageFile(_HIcon.Imagem);
                sb.Append("\t\t\tjava.awt.Image image = ImagesController.getInstance().getImage(\"").Append(imageFile.FileNameWithExtension).Append("\");\n");
                sb.Append("\t\t\tif (image != null) {\n");
                sb.Append("\t\t\t\tthis.").Append(_HIcon.NameStartedWithLowerCase).Append(".setGraphicContent(image, org.havi.ui.HVisible.NORMAL_STATE);\n");
                //sb.Append("\t\t\t\tint width = image.getWidth(null);\n");
                //sb.Append("\t\t\t\tint height = image.getHeight(null);\n");
                //sb.Append("\t\t\t\tthis.").Append(_HIcon.NameStartedWithLowerCase).Append(".setSize(width, height);\n");
                sb.Append("\t\t\t}\n");
            }
        }
    }
}
